<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <th:block th:include="fragments/header :: header"/>
    <script type="text/javascript" th:inline="none">

        $(function () {
            initDataGrid();
            initToolbar();
        });
        //初始化表格
        function initDataGrid() {
            $("#dgPlayerList").datagrid({
                url:'/markt/player/list',
                idField:'id',
                frozenColumns:[[
                    {field:'ck',checkbox:true}
                ]],
                columns:[[
                    {field: 'number', title: '号码', width: 80},
                    {field: 'name', title: '姓名', width: 80},
                    {field: 'age', title: '年龄', width: 120},
                    {field: 'nat', title: '国籍', width: 80},
                    {field: 'clubName', title: '俱乐部', width: 80},
                    {field: 'height', title: '身高', width: 80},
                    {field: 'isForeigner', title: '是否是外援', width: 80,formatter(value,row,index){
                        if (value==0){
                            return "否";
                        }else if (value==1){
                            return "是";
                        }else {
                            return "无";
                        }
                        }},
                    {field: 'internationalMatches', title: '比赛场次', width: 80},
                    {field: 'marketValue', title: '身价', width: 80}
                ]],
                pagination:true,
                rownumbers:true,
                fit:true,
                toolbar:'#dgPlayerList-toolbar'
            });
        }
        //初始化工具条
        function initToolbar() {
            $("#btnAdd").click(function () {
                layer.open({
                    type:2,
                    area:['500px','300px'],
                    content:'/markt/player/add',
                    end: function () {
                        $("#dgPlayerList").datagrid("reload");
                    }
                });
            });

            $("#btnEdit").click(function () {
                var sel = $("#dgPlayerList").datagrid('getSelected');
                if (sel) {
                    layer.open({
                        type: 2,
                        area:['500px','300px'],
                        content: '/markt/player/edit/' + sel.id,
                        end: function () {
                            $("#dgPlayerList").datagrid("reload");
                        }
                    });
                }
            });

            $("#btnRemove").click(function () {
                DataGridUtil.Delete("/markt/player/doDelete","dgPlayerList");
            });

            $("#btnImportExcel").click(function () {
                layer.open({
                    type:2,
                    content: '/markt/importExcel?type=player',
                    area:['500px','300px'],
                    end:function () {
                        window.parent.location.reload();
                    }
                })
            });
        }
    </script>
</head>
<body class="easyui-layout">
<div id="dgPlayerList-toolbar" style="padding: 2px 0;" class="datagrid-toolbar">
    <table cellpadding="0" cellspacing="0" style="width: 100%">
        <tr>
            <td style="padding-left: 2px">
                <a id="btnAdd" href="javascript:void(0)" class="easyui-linkbutton" style="float: left">新增</a>
                <a id="btnEdit" href="javascript:void(0)" class="easyui-linkbutton" style="float: left">编辑</a>
                <a id="btnRemove" href="javascript:void(0)" class="easyui-linkbutton" style="float: left">删除</a>
                <div class="datagrid-btn-separator"></div>
                <a id="btnImportExcel" href="javascript:void(0)" class="easyui-linkbutton">导入Excel</a>
            </td>
        </tr>
    </table>
</div>
<div data-options="region:'center'">
    <table id="dgPlayerList">
    </table>
</div>
</body>
</html>
